﻿//----------------------------------------------------

#region 命名空间

//    版权：
//    作者：
//建立时间：2012-09-11 00:00:33
//    描述：
//----------------------------------------------------
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using WinnerCMS.Common;
using WinnerCMS.Data;
using WinnerCMS.Model;

#endregion

namespace WinnerCMS.BLL
{
    /// <summary>
    /// 业务逻辑类 WinnerCMS_Delivery 的摘要说明。
    /// </summary>
    public class DeliveryManage
    {
        private static readonly DeliveryDal Dal = new DeliveryDal();

        #region 添加

        /// <summary>
        /// 添加
        /// </summary>
        public Result Add(Delivery model)
        {
            Result resu = new Result();
            if (model.HandlerName.Length == 0)
            {
                resu.Errors = "“”不能为空！";
                return resu;
            }
            if (model.ExpressCompany.Length == 0)
            {
                resu.Errors = "“”不能为空！";
                return resu;
            }
            if (model.ExpressNumber.Length == 0)
            {
                resu.Errors = "“”不能为空！";
                return resu;
            }
            if (model.Admin == 0)
            {
                resu.Errors = "“”不能为空！";
                return resu;
            }


            if (model.Id == 0)
            {
                Dal.Add(model);
            }
            else
            {
                Dal.Edit(model);
            }
            return resu;
        }

        #endregion

        #region 删除

        /// <summary>
        /// 删除
        /// </summary>
        public void Delete(string ids, UpdatePanel UpdatePanel1)
        {
            if (string.IsNullOrEmpty(ids))
            {
                MsgBox.Message("至少选择一项。", UpdatePanel1);
            }
            else
            {
                Dal.Delete(MyConvert.ConvertToArr(ids));
            }
        }

        #endregion

        #region 加载数据

        /// <summary>
        /// 加载数据
        /// </summary>
        public Delivery GetInfo(int id)
        {
            return Dal.GetInfo(id);
        }

        #endregion

        /// <summary>
        /// 绑定分页数据
        /// </summary>
        /// <param name="pp"></param>
        /// <returns></returns>
        public IList<Delivery> BindList(PagingParam pp)
        {
            return Dal.BindList(pp);
        }
    }
}